﻿Namespace Diagnostics.Profiler
    Friend NotInheritable Class MethodCall
        Private _entryTime As Date
        Private _exitTime As Date
        Private _callerSpan As TimeSpan

        Friend Sub New()
            _entryTime = Date.Now
            _callerSpan = TimeSpan.Zero
        End Sub

        Friend Sub AddCallerSpan(ByVal span As TimeSpan)
            _callerSpan += span
        End Sub

        Friend Sub ExitMethod()
            _exitTime = Date.Now
        End Sub

        Friend ReadOnly Property CallingSpan() As TimeSpan
            Get
                Return (_exitTime - _entryTime) - _callerSpan
            End Get
        End Property

        Friend ReadOnly Property CallingFullSpan() As TimeSpan
            Get
                Return _exitTime - _entryTime
            End Get
        End Property
    End Class
End Namespace
